<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script type="text/javascript">
		window.onload=function () {
			// body...
			var oInput1 = document.getElementById("input01");
			var oInput2 = document.getElementById("input02");
			var oBtn = document.getElementById("btn");


			oBtn.onclick = function(){
				var val01 = oInput1.value;
				var val02 = oInput2.value;
				var res = add(val01,val02)
				alert(res);
			}

			function add(a,b){
				var c = parseInt(a) + parseInt(b);
				// return 返回函数值,同时结束函数
				return c;
			}
		}
	</script>
</head>
<body>
	<input type="text" name="" id="input01">
	<input type="text" name="" id="input02">
	<input type="button" name="" value="相加" id="btn">
</body>
</html>